using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class forums_controls_threads_ThreadHeaderFooter : Controls.DataManagerThreadControl
{

    private DAL.User CurrentUser
    {
        get
        {
            return Managers.UserLoginManager.CurrentUser;
        }
    }

    protected override void ItemChanged()
    {
        lnkReply.Visible = false;

        if (CurrentThread != null)
        {
            Pager1.UrlFormat = Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}&page={{0}}", CurrentItem.ID);
            Pager1.TotalPages = CurrentItem.TotalPages;

            if (CurrentUser != null)
            {
                lnkReply.Visible = true;
                if (CurrentUser.HasPermissions(DAL.User.UserStatus.Moderator) || CurrentThread.Status == DAL.Thread.ThreadStatus.Open)
                {
                    lnkReply.NavigateUrl = String.Format("~/forums/newpost.aspx?t={0}", CurrentThread.ID);
                    lnkReply.Text = "Reply";
                }
                else
                {
                    lnkReply.NavigateUrl = "";
                    lnkReply.Text = "Thread Locked";
                }
            }
        }
        else
        {
            Pager1.UrlFormat = "";
            Pager1.TotalPages = 0;
        }
    }

    public int CurrentPage
    {
        get
        {
            return Pager1.CurrentPage;
        }
        set
        {
            Pager1.CurrentPage = value;
        }
    }
}
